package com.asdhawaii.otello.board;

/**
 * One of eight directions that one may move in on a two-dimensional plane.
 * 
 * @author Branden Ogata
 *
 */

public enum Direction
{
  /**
   * North; y - 1.
   * 
   */
  N,

  /**
   * Northeast; x + 1,  y - 1.
   * 
   */
  NE,

  /**
   * East; x + 1.
   * 
   */
  E,

  /**
   * Southeast; x + 1, y + 1.
   * 
   */
  SE,

  /**
   * South; y + 1.
   * 
   */
  S,

  /**
   * Southwest; x - 1, y + 1.
   * 
   */
  SW,

  /**
   * West; x - 1.
   * 
   */
  W,

  /**
   * Northwest; x - 1, y - 1.
   * 
   */
  NW;

  /**
   * Returns the change in x for this Direction.
   * 
   * @return delta The int equal to the change in x for a single step in this Direction.
   * 
   */
  
  public int getDeltaX()
  {
    int delta = 0;
    
    switch (this)
    {
      case NW:
      case W:
      case SW:
        delta = -1;
        break;
      case NE:
      case E:
      case SE:
        delta = 1;
        break;
      default:
        break;
    }
    
    return delta;
  }
  
  /**
   * Returns the change in y for this Direction.
   * 
   * @return delta The int equal to the change in y for a single step in this Direction.
   * 
   */
  
  public int getDeltaY()
  {
    int delta = 0;
    
    switch (this)
    {
      case NW:
      case N:
      case NE:
        delta = -1;
        break;
      case SW:
      case S:
      case SE:
        delta = 1;
        break;
      default:
        break;
    }
    
    return delta;
  }  
}
